﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class zhuce : Form
    {
        private SqlConnection sup;

        public zhuce()
        {
            InitializeComponent();
        }

        private void zhuce_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            var uid = textBox1.Text;
            var pwd = textBox2.Text;
            var pwd1 = textBox3.Text;
            if (uid == "")
            {
                MessageBox.Show("请输入账号");
            }
            else if (pwd == "")
            {
                MessageBox.Show("请输入密码");
            }
            else if (pwd1 == "")
            {
                MessageBox.Show("请确认密码");
            }
            else
            {
                if (pwd == pwd1)
                {
                    string Sql = "server=.;database=Blogs;uid=sa;pwd=123456";
                    sup = new SqlConnection(Sql);
                    string cmd = string.Format("insert into Users values('{0}','{1}')", uid, pwd);
                    SqlCommand com = new SqlCommand(cmd, sup);
                    sup.Open();
                    if (com.ExecuteNonQuery() != 0)
                        MessageBox.Show("恭喜你注册成功！");
                    else
                        MessageBox.Show("对不起注册失败！");
                    sup.Close();
                }
                else
                {
                    MessageBox.Show("两次输入密码不一致！");
                }
            }

        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }
    }
}
